package ch02.shiLi;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.io.File;
import java.util.Iterator;

public class showPhoneInfo {
    public static void main(String[] args) throws DocumentException {
     //读取xml文件
        SAXReader saxReader = new SAXReader();
        Document doc = saxReader.read(new File("src/ch02/shiLi/收藏信息.xml"));
        Element root = doc.getRootElement();
        for(Iterator iterator=root.elementIterator();iterator.hasNext();){
            Element brand = (Element) iterator.next();
            System.out.println("品牌" + brand.attributeValue("name"));
            for (Iterator itType=brand.elementIterator();itType.hasNext();){
                Element type = (Element) itType.next();
                System.out.println("\t型号" + type.attributeValue("name"));

            }
        }


    }
}
